<?php
/*
<Controller Information> 
Author: Naseer Ahmad
Date: 19-10-2011
Last Updated on:  
*/

class adManagerController extends appController
{
	function index()
	{
		
		if(isset($this->data['filter'])) $filter=$this->data['filter']; else $filter="All";
		$this -> set("filter", $filter);
		
		if($filter=="All") 
			$criteria="1=1"; 
		else
			if($filter=="Featured") $criteria="isFeatured=1"; else $criteria="status='".$filter."'";
		
		$adData = $this -> adManager -> getAdData($criteria, $this->makeLimit());
		//print "<pre>";
		//print_r($adData);
		//print "</pre>";
		//exit;
		
		$this -> set("adData", $adData['data']);
		$this -> set("tRec", $adData['tRec']);
		
		//////// get Stats
		$st =  $this -> adManager -> getStatistics();
		$this -> set("stats", $st);
		
		$this -> render('Ads. Manager');
	}
	
	
	function updateStatus(){
		$fv=array("status"	=> $this->data['status']);
		$where = array("adID"	=> $this->data['adID']);
		$rs = $this -> usersManager -> _updateTable("adInfo", $fv, $where);
		if($rs) $cmd="Ad. Status Successfully Changed!"; else $cmd=$this -> usersManager -> getError();
		$rdArr = array("page"	=> "adManager",
				 "cmd"		=> $cmd);
		$this->redirect($rdArr);
	}
	
}
?>